Finalizing.. still need to debug, but the code should work as it is