Merge pull request #339 from dubslow/master

Fix #331, remove duplicate code