First version of rewritten script with classes