Tested codes. No refactoring yet