complete rememplemtation. still needs work