made nil/empty checks more idiomatic