Move empty/nil checking to the model

Close #35