removed unnecessary ";" from sql queries and improved add_sql_limit function