Moved if-statements into a single one