Updated with Samarth's changes.