First functional version [work still in progress]