Added some null checks, changed way it saves