added if clausules for safety