fixed verious errors and improved some code syntax