Cleaned code. Using right return value. Improved logs.