simplify and handle where result can be nil
Merge pull request #26 from vipulnsward/simplify_v0

simplify and handle where result can be nil