Fixed check to insert things on db