fixed bug with error being thrown unnessiarily