code is still very ugly, however it has been updated to the latest libs and works