modal box function and exchanged code from controllers