Simplify, add comments, add nil check