Added logging
Added comments for SQL