refactored by Sonechka