Cleaned up, some error checking