some nil checks and formatting | should fix #12