Working, will need more testing and minior bug fixes