The function was not returning error codes

Now it should work fine

More...