First version of a complete working script