Solved the problem and added in a few extra features