Bug fixes error checking