Added preview logic. Most of the logic in place