refactored code, worked on euler cycle