Cleaned code - alpha version