Removed some duplicated code that contain errors, fixing #12.