refactored parse
fixed bugs