Fixed and tested the basic functionality