Made checks into appropriate functions