Looks like you have some duplicate code here. Looks pretty good to merge after that.